package com.betterjr.modules.risk.loan.entity;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.common.utils.BTAssert;
import com.betterjr.common.utils.BetterDateUtils;
import com.betterjr.common.utils.BetterStringUtils;
import com.betterjr.common.utils.Collections3;
import com.betterjr.common.utils.UserUtils;
import com.betterjr.modules.account.entity.CustOperatorInfo;
import com.betterjr.modules.generator.SequenceFactory;
import com.betterjr.modules.risk.loan.data.LoanProjectElcAgreementConstantCollections;
import com.betterjr.modules.risk.loan.data.LoanProjectRelationConstantCollections;

@Access(AccessType.FIELD)
@Entity
@Table(name = "t_scf_loanproject_relation")
public class LoanProjectRelation implements BetterjrEntity {

    /** 
     * @Fields serialVersionUID : 
     */
    private static final long serialVersionUID = -289206084790921399L;

    /**
     * 流水号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "流水号", comments = "流水号")
    private Long id;

    /**
     * 合同名称
     */
    @Column(name = "C_ELCAGGREMENT_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "合同名称", comments = "合同名称")
    private String elcAggrementName;

    /**
     * 贷款合同号
     */
    @Column(name = "C_LOANAGGREMENT_NO", columnDefinition = "VARCHAR")
    @MetaData(value = "贷款合同号", comments = "贷款合同号")
    private String loanAggrementNo;

    /**
     * 供应商名称
     */
    @Column(name = "C_CUST_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "供应商名称", comments = "供应商名称")
    private String custName;

    /**
     * 供应商编号
     */
    @Column(name = "L_CUSTNO", columnDefinition = "INTEGER")
    @MetaData(value = "供应商编号", comments = "供应商编号")
    private Long custNo;

    /**
     * 供应商企业代码
     */
    @Column(name = "C_CUSTCODE", columnDefinition = "VARCHAR")
    @MetaData(value = "供应商企业代码", comments = "供应商企业代码")
    private String custCode;

    /**
     * 核心企业名称
     */
    @Column(name = "C_CORE_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "核心企业名称", comments = "核心企业名称")
    private String coreName;

    /**
     * 核心企业编号
     */
    @Column(name = "L_CORENO", columnDefinition = "INTEGER")
    @MetaData(value = "核心企业编号", comments = "核心企业编号")
    private Long coreNo;

    /**
     * 资金提供方名称
     */
    @Column(name = "C_FACTORY_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "资金提供方名称", comments = "资金提供方名称")
    private String factoryName;

    /**
     * 资金提供方编号
     */
    @Column(name = "L_FACTORYNO", columnDefinition = "INTEGER")
    @MetaData(value = "资金提供方编号", comments = "资金提供方编号")
    private Long factoryNo;

    /**
     * 交易应付金额
     */
    @Column(name = "F_BALANCE", columnDefinition = "DOUBLE")
    @MetaData(value = "交易应付金额", comments = "交易应付金额")
    private BigDecimal balance;

    /**
     * 放款金额
     */
    @Column(name = "F_LOAN_BALANCE", columnDefinition = "DOUBLE")
    @MetaData(value = "放款金额", comments = "放款金额")
    private BigDecimal loanBalance;

    /**
     * 交易应付日期
     */
    @Column(name = "C_PAY_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "交易应付日期", comments = "交易应付日期")
    private String payDate;

    /**
     * 交易应付时间
     */
    @Column(name = "C_PAY_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "交易应付时间", comments = "交易应付时间")
    private String payTime;

    /**
     * 折扣
     */
    @Column(name = "F_DISCOUNT", columnDefinition = "DOUBLE")
    @MetaData(value = "折扣", comments = "折扣")
    private BigDecimal discount;

    /**
     * 放款日期
     */
    @Column(name = "C_LOAN_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "放款日期", comments = "放款日期")
    private String loanDate;

    /**
     * 0 未生效  1：正常  2放款成功 3 结束  4 作废 9暂存
     */
    @Column(name = "C_BUSINSTATUS", columnDefinition = "VARCHAR")
    @MetaData(value = "0 未生效  1：正常  2放款成功 3 结束  4 作废 9暂存", comments = "0 未生效  1：正常  2放款成功 3 结束  4 作废 9暂存")
    private String businStatus;

    /**
     * 创建日期
     */
    @Column(name = "C_CREATE_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "创建日期", comments = "创建日期")
    private String createDate;

    /**
     * 创建时间
     */
    @Column(name = "C_CREATE_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "创建时间", comments = "创建时间")
    private String createTime;

    /**
     *创建人名称
     */
    @Column(name = "C_CREATE_OPERATORNAME", columnDefinition = "VARCHAR")
    @MetaData(value = "创建人名称", comments = "创建人名称")
    private String createOperatorName;

    /**
     * 创建人id
     */
    @Column(name = "N_CREATE_OPERATORID", columnDefinition = "INTEGER")
    @MetaData(value = "创建人id", comments = "创建人id")
    private Long createOperatorId;

    /**
     * 复核日期
     */
    @Column(name = "C_AUDIT_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "复核日期", comments = "复核日期")
    private String auditDate;

    /**
     * 复核时间
     */
    @Column(name = "C_AUDIT_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "复核时间", comments = "复核时间")
    private String auditTime;

    /**
     *复核人名称
     */
    @Column(name = "C_AUDIT_OPERATORNAME", columnDefinition = "VARCHAR")
    @MetaData(value = "复核人名称", comments = "复核人名称")
    private String auditOperatorName;

    /**
     * 复核人id
     */
    @Column(name = "N_AUDIT_OPERATORID", columnDefinition = "INTEGER")
    @MetaData(value = "复核人id", comments = "复核人id")
    private Long auditOperatorId;

    /**
     * 放款录入日期
     */
    @Column(name = "C_FACTORYLOAN_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "放款录入日期", comments = "放款录入日期")
    private String factoryLoanDate;

    /**
     * 放款录入时间
     */
    @Column(name = "C_FACTORYLOAN_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "放款录入时间", comments = "放款录入时间")
    private String factoryLoanTime;

    /**
     *放款录入人名称
     */
    @Column(name = "C_FACTORYLOAN_OPERATORNAME", columnDefinition = "VARCHAR")
    @MetaData(value = "放款录入人名称", comments = "放款录入人名称")
    private String factoryLoanOperatorName;

    /**
     * 放款录入人id
     */
    @Column(name = "N_FACTORYLOAN_OPERATORID", columnDefinition = "INTEGER")
    @MetaData(value = "放款录入人id", comments = "放款录入人id")
    private Long factoryLoanOperatorId;

    /**
     * 平台服务费率
     */
    @Column(name = "F_SERVICE_RATE", columnDefinition = "DOUBLE")
    @MetaData(value = "平台服务费率", comments = "平台服务费率")
    private BigDecimal serviceRate;

    /**
     *扣款规则 1 只勾选了第一个     2 只勾选了第二个  4 只勾选了第三个 3 勾选了前两个依次类推
     */
    @Column(name = "C_WITHHOLD_RULE", columnDefinition = "VARCHAR")
    @MetaData(value = "扣款规则 1 只勾选了第一个     2 只勾选了第二个  4 只勾选了第三个 3 勾选了前两个依次类推", comments = "扣款规则 1 只勾选了第一个     2 只勾选了第二个  4 只勾选了第三个 3 勾选了前两个依次类推")
    private String withHoldRule;

    /**
     * 融资期限
     */
    @Column(name = "N_FINANCINGMATURITY_DATE", columnDefinition = "INTEGER")
    @MetaData(value = "融资期限", comments = "融资期限")
    private Long financingMaturityDate;

    /**
     * 账户监管协议
     */
    @Transient
    private LoanProjectElcAgreement accountRegulatoryAgreement;

    /**
     * 平台服务费协议
     */
    @Transient
    private LoanProjectElcAgreement platformServiceAgreement;

    /**
     * 数据确权协议
     */
    @Transient
    private LoanProjectElcAgreement dataConfirmationAgreement;

    /**
     * 其他协议
     */
    @Transient
    private List<LoanProjectElcAgreement> otherAgreements = new ArrayList<>(1);

    /**
     * 供应商监管账户
     */
    @Transient
    private List<LoanProjectBank> custAccountRegulatoryBank = new ArrayList<>(1);

    /**
     * 供应商监管账户ids （银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custAccountRegulatoryBankIds;

    /**
     * 供应商可归集账户
     */
    @Transient
    private List<LoanProjectBank> custAggregationBank = new ArrayList<>(1);

    /**
     * 供应商可归集账户（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custAggregationBankIds;

    /**
     * 供应商收款帐号
     */
    @Transient
    private LoanProjectBank custGatheringBank;

    /**
     * 供应商收款帐号（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custGatheringBankIds;

    /**
     * 供应商扣款本金帐号
     */
    @Transient
    private LoanProjectBank custWithHoldPrincipalBank;

    /**
     * 供应商扣款本金帐号（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custWithHoldPrincipalBankIds;

    /**
     * 供应商扣款利息帐号
     */
    @Transient
    private LoanProjectBank custWithHoldInterestBank;

    /**
     * 供应商扣款利息帐号（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custWithHoldInterestBankIds;

    /**
     * 资金方放款账户
     */
    @Transient
    private LoanProjectBank factoryLoanBank;

    /**
     * 资金方放款账户（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String factoryLoanBankIds;

    /**
     * 资金方收款本金账户
     */
    @Transient
    private LoanProjectBank factoryGatheringPrincipalBank;

    /**
     * 资金方收款本金账户（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String factoryGatheringPrincipalBankIds;

    /**
     * 资金方收款利息账户
     */
    @Transient
    private LoanProjectBank factoryGatheringInterestBank;

    /**
     * 资金方收款利息账户（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String factoryGatheringInterestBankIds;

    /**
     * 供应商付服务费账户
     */
    @Transient
    private LoanProjectBank custPayServiceBank;

    /**
     * 供应商付服务费账户（银行表id,银行表id） 方便前端操作
     */
    @Transient
    private String custPayServiceBankIds;

    @Transient
    private List<LoanTransactionRelation> transactionRelations = new ArrayList<>(1);

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getElcAggrementName() {
        return elcAggrementName;
    }

    public void setElcAggrementName(String elcAggrementName) {
        this.elcAggrementName = elcAggrementName;
    }

    public String getLoanAggrementNo() {
        return loanAggrementNo;
    }

    public void setLoanAggrementNo(String loanAggrementNo) {
        this.loanAggrementNo = loanAggrementNo;
    }

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public Long getCustNo() {
        return custNo;
    }

    public void setCustNo(Long custNo) {
        this.custNo = custNo;
    }

    public String getCustCode() {
        return custCode;
    }

    public void setCustCode(String custCode) {
        this.custCode = custCode;
    }

    public String getCoreName() {
        return coreName;
    }

    public void setCoreName(String coreName) {
        this.coreName = coreName;
    }

    public Long getCoreNo() {
        return coreNo;
    }

    public void setCoreNo(Long coreNo) {
        this.coreNo = coreNo;
    }

    public String getFactoryName() {
        return factoryName;
    }

    public void setFactoryName(String factoryName) {
        this.factoryName = factoryName;
    }

    public Long getFactoryNo() {
        return factoryNo;
    }

    public void setFactoryNo(Long factoryNo) {
        this.factoryNo = factoryNo;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    public BigDecimal getLoanBalance() {
        return loanBalance;
    }

    public void setLoanBalance(BigDecimal loanBalance) {
        this.loanBalance = loanBalance;
    }

    public String getPayDate() {
        return payDate;
    }

    public void setPayDate(String payDate) {
        this.payDate = payDate;
    }

    public String getPayTime() {
        return payTime;
    }

    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

    public String getLoanDate() {
        return loanDate;
    }

    public void setLoanDate(String loanDate) {
        this.loanDate = loanDate;
    }

    public String getBusinStatus() {
        return businStatus;
    }

    public void setBusinStatus(String businStatus) {
        this.businStatus = businStatus;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getCreateOperatorName() {
        return createOperatorName;
    }

    public void setCreateOperatorName(String createOperatorName) {
        this.createOperatorName = createOperatorName;
    }

    public Long getCreateOperatorId() {
        return createOperatorId;
    }

    public void setCreateOperatorId(Long createOperatorId) {
        this.createOperatorId = createOperatorId;
    }

    public String getAuditDate() {
        return auditDate;
    }

    public void setAuditDate(String auditDate) {
        this.auditDate = auditDate;
    }

    public String getAuditTime() {
        return auditTime;
    }

    public void setAuditTime(String auditTime) {
        this.auditTime = auditTime;
    }

    public String getAuditOperatorName() {
        return auditOperatorName;
    }

    public void setAuditOperatorName(String auditOperatorName) {
        this.auditOperatorName = auditOperatorName;
    }

    public Long getAuditOperatorId() {
        return auditOperatorId;
    }

    public void setAuditOperatorId(Long auditOperatorId) {
        this.auditOperatorId = auditOperatorId;
    }

    public String getFactoryLoanDate() {
        return factoryLoanDate;
    }

    public void setFactoryLoanDate(String factoryLoanDate) {
        this.factoryLoanDate = factoryLoanDate;
    }

    public String getFactoryLoanTime() {
        return factoryLoanTime;
    }

    public void setFactoryLoanTime(String factoryLoanTime) {
        this.factoryLoanTime = factoryLoanTime;
    }

    public String getFactoryLoanOperatorName() {
        return factoryLoanOperatorName;
    }

    public void setFactoryLoanOperatorName(String factoryLoanOperatorName) {
        this.factoryLoanOperatorName = factoryLoanOperatorName;
    }

    public Long getFactoryLoanOperatorId() {
        return factoryLoanOperatorId;
    }

    public void setFactoryLoanOperatorId(Long factoryLoanOperatorId) {
        this.factoryLoanOperatorId = factoryLoanOperatorId;
    }

    public BigDecimal getServiceRate() {
        return serviceRate;
    }

    public void setServiceRate(BigDecimal serviceRate) {
        this.serviceRate = serviceRate;
    }

    public String getWithHoldRule() {
        return withHoldRule;
    }

    public void setWithHoldRule(String withHoldRule) {
        this.withHoldRule = withHoldRule;
    }

    public Long getFinancingMaturityDate() {
        return financingMaturityDate;
    }

    public void setFinancingMaturityDate(Long financingMaturityDate) {
        this.financingMaturityDate = financingMaturityDate;
    }

    public LoanProjectElcAgreement getAccountRegulatoryAgreement() {
        return accountRegulatoryAgreement;
    }

    public void setAccountRegulatoryAgreement(LoanProjectElcAgreement accountRegulatoryAgreement) {
        this.accountRegulatoryAgreement = accountRegulatoryAgreement;
    }

    public LoanProjectElcAgreement getPlatformServiceAgreement() {
        return platformServiceAgreement;
    }

    public void setPlatformServiceAgreement(LoanProjectElcAgreement platformServiceAgreement) {
        this.platformServiceAgreement = platformServiceAgreement;
    }

    public LoanProjectElcAgreement getDataConfirmationAgreement() {
        return dataConfirmationAgreement;
    }

    public void setDataConfirmationAgreement(LoanProjectElcAgreement dataConfirmationAgreement) {
        this.dataConfirmationAgreement = dataConfirmationAgreement;
    }

    public List<LoanProjectElcAgreement> getOtherAgreements() {
        return otherAgreements;
    }

    public void setOtherAgreements(List<LoanProjectElcAgreement> otherAgreements) {
        this.otherAgreements = otherAgreements;
    }

    public List<LoanProjectBank> getCustAccountRegulatoryBank() {
        return custAccountRegulatoryBank;
    }

    public void setCustAccountRegulatoryBank(List<LoanProjectBank> custAccountRegulatoryBank) {
        this.custAccountRegulatoryBank = custAccountRegulatoryBank;
    }

    public List<LoanProjectBank> getCustAggregationBank() {
        return custAggregationBank;
    }

    public void setCustAggregationBank(List<LoanProjectBank> custAggregationBank) {
        this.custAggregationBank = custAggregationBank;
    }

    public LoanProjectBank getCustGatheringBank() {
        return custGatheringBank;
    }

    public void setCustGatheringBank(LoanProjectBank custGatheringBank) {
        this.custGatheringBank = custGatheringBank;
    }

    public LoanProjectBank getCustWithHoldPrincipalBank() {
        return custWithHoldPrincipalBank;
    }

    public void setCustWithHoldPrincipalBank(LoanProjectBank custWithHoldPrincipalBank) {
        this.custWithHoldPrincipalBank = custWithHoldPrincipalBank;
    }

    public LoanProjectBank getCustWithHoldInterestBank() {
        return custWithHoldInterestBank;
    }

    public void setCustWithHoldInterestBank(LoanProjectBank custWithHoldInterestBank) {
        this.custWithHoldInterestBank = custWithHoldInterestBank;
    }

    public LoanProjectBank getFactoryLoanBank() {
        return factoryLoanBank;
    }

    public void setFactoryLoanBank(LoanProjectBank factoryLoanBank) {
        this.factoryLoanBank = factoryLoanBank;
    }

    public LoanProjectBank getFactoryGatheringPrincipalBank() {
        return factoryGatheringPrincipalBank;
    }

    public void setFactoryGatheringPrincipalBank(LoanProjectBank factoryGatheringPrincipalBank) {
        this.factoryGatheringPrincipalBank = factoryGatheringPrincipalBank;
    }

    public LoanProjectBank getFactoryGatheringInterestBank() {
        return factoryGatheringInterestBank;
    }

    public void setFactoryGatheringInterestBank(LoanProjectBank factoryGatheringInterestBank) {
        this.factoryGatheringInterestBank = factoryGatheringInterestBank;
    }

    public LoanProjectBank getCustPayServiceBank() {
        return custPayServiceBank;
    }

    public void setCustPayServiceBank(LoanProjectBank custPayServiceBank) {
        this.custPayServiceBank = custPayServiceBank;
    }

    public String getCustAccountRegulatoryBankIds() {
        return custAccountRegulatoryBankIds;
    }

    public void setCustAccountRegulatoryBankIds(String custAccountRegulatoryBankIds) {
        this.custAccountRegulatoryBankIds = custAccountRegulatoryBankIds;
    }

    public String getCustAggregationBankIds() {
        return custAggregationBankIds;
    }

    public void setCustAggregationBankIds(String custAggregationBankIds) {
        this.custAggregationBankIds = custAggregationBankIds;
    }

    public String getCustGatheringBankIds() {
        return custGatheringBankIds;
    }

    public void setCustGatheringBankIds(String custGatheringBankIds) {
        this.custGatheringBankIds = custGatheringBankIds;
    }

    public String getCustWithHoldPrincipalBankIds() {
        return custWithHoldPrincipalBankIds;
    }

    public void setCustWithHoldPrincipalBankIds(String custWithHoldPrincipalBankIds) {
        this.custWithHoldPrincipalBankIds = custWithHoldPrincipalBankIds;
    }

    public String getCustWithHoldInterestBankIds() {
        return custWithHoldInterestBankIds;
    }

    public void setCustWithHoldInterestBankIds(String custWithHoldInterestBankIds) {
        this.custWithHoldInterestBankIds = custWithHoldInterestBankIds;
    }

    public String getFactoryLoanBankIds() {
        return factoryLoanBankIds;
    }

    public void setFactoryLoanBankIds(String factoryLoanBankIds) {
        this.factoryLoanBankIds = factoryLoanBankIds;
    }

    public String getFactoryGatheringPrincipalBankIds() {
        return factoryGatheringPrincipalBankIds;
    }

    public void setFactoryGatheringPrincipalBankIds(String factoryGatheringPrincipalBankIds) {
        this.factoryGatheringPrincipalBankIds = factoryGatheringPrincipalBankIds;
    }

    public String getFactoryGatheringInterestBankIds() {
        return factoryGatheringInterestBankIds;
    }

    public void setFactoryGatheringInterestBankIds(String factoryGatheringInterestBankIds) {
        this.factoryGatheringInterestBankIds = factoryGatheringInterestBankIds;
    }

    public String getCustPayServiceBankIds() {
        return custPayServiceBankIds;
    }

    public void setCustPayServiceBankIds(String custPayServiceBankIds) {
        this.custPayServiceBankIds = custPayServiceBankIds;
    }

    public List<LoanTransactionRelation> getTransactionRelations() {
        return transactionRelations;
    }

    public void setTransactionRelations(List<LoanTransactionRelation> transactionRelations) {
        this.transactionRelations = transactionRelations;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((accountRegulatoryAgreement == null) ? 0 : accountRegulatoryAgreement.hashCode());
        result = prime * result + ((auditDate == null) ? 0 : auditDate.hashCode());
        result = prime * result + ((auditOperatorId == null) ? 0 : auditOperatorId.hashCode());
        result = prime * result + ((auditOperatorName == null) ? 0 : auditOperatorName.hashCode());
        result = prime * result + ((auditTime == null) ? 0 : auditTime.hashCode());
        result = prime * result + ((balance == null) ? 0 : balance.hashCode());
        result = prime * result + ((businStatus == null) ? 0 : businStatus.hashCode());
        result = prime * result + ((coreName == null) ? 0 : coreName.hashCode());
        result = prime * result + ((coreNo == null) ? 0 : coreNo.hashCode());
        result = prime * result + ((createDate == null) ? 0 : createDate.hashCode());
        result = prime * result + ((createOperatorId == null) ? 0 : createOperatorId.hashCode());
        result = prime * result + ((createOperatorName == null) ? 0 : createOperatorName.hashCode());
        result = prime * result + ((createTime == null) ? 0 : createTime.hashCode());
        result = prime * result + ((custAccountRegulatoryBank == null) ? 0 : custAccountRegulatoryBank.hashCode());
        result = prime * result + ((custAggregationBank == null) ? 0 : custAggregationBank.hashCode());
        result = prime * result + ((custCode == null) ? 0 : custCode.hashCode());
        result = prime * result + ((custGatheringBank == null) ? 0 : custGatheringBank.hashCode());
        result = prime * result + ((custName == null) ? 0 : custName.hashCode());
        result = prime * result + ((custNo == null) ? 0 : custNo.hashCode());
        result = prime * result + ((custPayServiceBank == null) ? 0 : custPayServiceBank.hashCode());
        result = prime * result + ((custWithHoldInterestBank == null) ? 0 : custWithHoldInterestBank.hashCode());
        result = prime * result + ((custWithHoldPrincipalBank == null) ? 0 : custWithHoldPrincipalBank.hashCode());
        result = prime * result + ((dataConfirmationAgreement == null) ? 0 : dataConfirmationAgreement.hashCode());
        result = prime * result + ((discount == null) ? 0 : discount.hashCode());
        result = prime * result + ((elcAggrementName == null) ? 0 : elcAggrementName.hashCode());
        result = prime * result
                + ((factoryGatheringInterestBank == null) ? 0 : factoryGatheringInterestBank.hashCode());
        result = prime * result
                + ((factoryGatheringPrincipalBank == null) ? 0 : factoryGatheringPrincipalBank.hashCode());
        result = prime * result + ((factoryLoanBank == null) ? 0 : factoryLoanBank.hashCode());
        result = prime * result + ((factoryLoanDate == null) ? 0 : factoryLoanDate.hashCode());
        result = prime * result + ((factoryLoanOperatorId == null) ? 0 : factoryLoanOperatorId.hashCode());
        result = prime * result + ((factoryLoanOperatorName == null) ? 0 : factoryLoanOperatorName.hashCode());
        result = prime * result + ((factoryLoanTime == null) ? 0 : factoryLoanTime.hashCode());
        result = prime * result + ((factoryName == null) ? 0 : factoryName.hashCode());
        result = prime * result + ((factoryNo == null) ? 0 : factoryNo.hashCode());
        result = prime * result + ((financingMaturityDate == null) ? 0 : financingMaturityDate.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((loanAggrementNo == null) ? 0 : loanAggrementNo.hashCode());
        result = prime * result + ((loanDate == null) ? 0 : loanDate.hashCode());
        result = prime * result + ((otherAgreements == null) ? 0 : otherAgreements.hashCode());
        result = prime * result + ((payDate == null) ? 0 : payDate.hashCode());
        result = prime * result + ((payTime == null) ? 0 : payTime.hashCode());
        result = prime * result + ((platformServiceAgreement == null) ? 0 : platformServiceAgreement.hashCode());
        result = prime * result + ((serviceRate == null) ? 0 : serviceRate.hashCode());
        result = prime * result + ((withHoldRule == null) ? 0 : withHoldRule.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof LoanProjectRelation)) {
            return false;
        }
        LoanProjectRelation other = (LoanProjectRelation) obj;
        if (accountRegulatoryAgreement == null) {
            if (other.accountRegulatoryAgreement != null) {
                return false;
            }
        } else if (!accountRegulatoryAgreement.equals(other.accountRegulatoryAgreement)) {
            return false;
        }
        if (auditDate == null) {
            if (other.auditDate != null) {
                return false;
            }
        } else if (!auditDate.equals(other.auditDate)) {
            return false;
        }
        if (auditOperatorId == null) {
            if (other.auditOperatorId != null) {
                return false;
            }
        } else if (!auditOperatorId.equals(other.auditOperatorId)) {
            return false;
        }
        if (auditOperatorName == null) {
            if (other.auditOperatorName != null) {
                return false;
            }
        } else if (!auditOperatorName.equals(other.auditOperatorName)) {
            return false;
        }
        if (auditTime == null) {
            if (other.auditTime != null) {
                return false;
            }
        } else if (!auditTime.equals(other.auditTime)) {
            return false;
        }
        if (balance == null) {
            if (other.balance != null) {
                return false;
            }
        } else if (!balance.equals(other.balance)) {
            return false;
        }
        if (businStatus == null) {
            if (other.businStatus != null) {
                return false;
            }
        } else if (!businStatus.equals(other.businStatus)) {
            return false;
        }
        if (coreName == null) {
            if (other.coreName != null) {
                return false;
            }
        } else if (!coreName.equals(other.coreName)) {
            return false;
        }
        if (coreNo == null) {
            if (other.coreNo != null) {
                return false;
            }
        } else if (!coreNo.equals(other.coreNo)) {
            return false;
        }
        if (createDate == null) {
            if (other.createDate != null) {
                return false;
            }
        } else if (!createDate.equals(other.createDate)) {
            return false;
        }
        if (createOperatorId == null) {
            if (other.createOperatorId != null) {
                return false;
            }
        } else if (!createOperatorId.equals(other.createOperatorId)) {
            return false;
        }
        if (createOperatorName == null) {
            if (other.createOperatorName != null) {
                return false;
            }
        } else if (!createOperatorName.equals(other.createOperatorName)) {
            return false;
        }
        if (createTime == null) {
            if (other.createTime != null) {
                return false;
            }
        } else if (!createTime.equals(other.createTime)) {
            return false;
        }
        if (custAccountRegulatoryBank == null) {
            if (other.custAccountRegulatoryBank != null) {
                return false;
            }
        } else if (!custAccountRegulatoryBank.equals(other.custAccountRegulatoryBank)) {
            return false;
        }
        if (custAggregationBank == null) {
            if (other.custAggregationBank != null) {
                return false;
            }
        } else if (!custAggregationBank.equals(other.custAggregationBank)) {
            return false;
        }
        if (custCode == null) {
            if (other.custCode != null) {
                return false;
            }
        } else if (!custCode.equals(other.custCode)) {
            return false;
        }
        if (custGatheringBank == null) {
            if (other.custGatheringBank != null) {
                return false;
            }
        } else if (!custGatheringBank.equals(other.custGatheringBank)) {
            return false;
        }
        if (custName == null) {
            if (other.custName != null) {
                return false;
            }
        } else if (!custName.equals(other.custName)) {
            return false;
        }
        if (custNo == null) {
            if (other.custNo != null) {
                return false;
            }
        } else if (!custNo.equals(other.custNo)) {
            return false;
        }
        if (custPayServiceBank == null) {
            if (other.custPayServiceBank != null) {
                return false;
            }
        } else if (!custPayServiceBank.equals(other.custPayServiceBank)) {
            return false;
        }
        if (custWithHoldInterestBank == null) {
            if (other.custWithHoldInterestBank != null) {
                return false;
            }
        } else if (!custWithHoldInterestBank.equals(other.custWithHoldInterestBank)) {
            return false;
        }
        if (custWithHoldPrincipalBank == null) {
            if (other.custWithHoldPrincipalBank != null) {
                return false;
            }
        } else if (!custWithHoldPrincipalBank.equals(other.custWithHoldPrincipalBank)) {
            return false;
        }
        if (dataConfirmationAgreement == null) {
            if (other.dataConfirmationAgreement != null) {
                return false;
            }
        } else if (!dataConfirmationAgreement.equals(other.dataConfirmationAgreement)) {
            return false;
        }
        if (discount == null) {
            if (other.discount != null) {
                return false;
            }
        } else if (!discount.equals(other.discount)) {
            return false;
        }
        if (elcAggrementName == null) {
            if (other.elcAggrementName != null) {
                return false;
            }
        } else if (!elcAggrementName.equals(other.elcAggrementName)) {
            return false;
        }
        if (factoryGatheringInterestBank == null) {
            if (other.factoryGatheringInterestBank != null) {
                return false;
            }
        } else if (!factoryGatheringInterestBank.equals(other.factoryGatheringInterestBank)) {
            return false;
        }
        if (factoryGatheringPrincipalBank == null) {
            if (other.factoryGatheringPrincipalBank != null) {
                return false;
            }
        } else if (!factoryGatheringPrincipalBank.equals(other.factoryGatheringPrincipalBank)) {
            return false;
        }
        if (factoryLoanBank == null) {
            if (other.factoryLoanBank != null) {
                return false;
            }
        } else if (!factoryLoanBank.equals(other.factoryLoanBank)) {
            return false;
        }
        if (factoryLoanDate == null) {
            if (other.factoryLoanDate != null) {
                return false;
            }
        } else if (!factoryLoanDate.equals(other.factoryLoanDate)) {
            return false;
        }
        if (factoryLoanOperatorId == null) {
            if (other.factoryLoanOperatorId != null) {
                return false;
            }
        } else if (!factoryLoanOperatorId.equals(other.factoryLoanOperatorId)) {
            return false;
        }
        if (factoryLoanOperatorName == null) {
            if (other.factoryLoanOperatorName != null) {
                return false;
            }
        } else if (!factoryLoanOperatorName.equals(other.factoryLoanOperatorName)) {
            return false;
        }
        if (factoryLoanTime == null) {
            if (other.factoryLoanTime != null) {
                return false;
            }
        } else if (!factoryLoanTime.equals(other.factoryLoanTime)) {
            return false;
        }
        if (factoryName == null) {
            if (other.factoryName != null) {
                return false;
            }
        } else if (!factoryName.equals(other.factoryName)) {
            return false;
        }
        if (factoryNo == null) {
            if (other.factoryNo != null) {
                return false;
            }
        } else if (!factoryNo.equals(other.factoryNo)) {
            return false;
        }
        if (financingMaturityDate == null) {
            if (other.financingMaturityDate != null) {
                return false;
            }
        } else if (!financingMaturityDate.equals(other.financingMaturityDate)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (loanAggrementNo == null) {
            if (other.loanAggrementNo != null) {
                return false;
            }
        } else if (!loanAggrementNo.equals(other.loanAggrementNo)) {
            return false;
        }
        if (loanDate == null) {
            if (other.loanDate != null) {
                return false;
            }
        } else if (!loanDate.equals(other.loanDate)) {
            return false;
        }
        if (otherAgreements == null) {
            if (other.otherAgreements != null) {
                return false;
            }
        } else if (!otherAgreements.equals(other.otherAgreements)) {
            return false;
        }
        if (payDate == null) {
            if (other.payDate != null) {
                return false;
            }
        } else if (!payDate.equals(other.payDate)) {
            return false;
        }
        if (payTime == null) {
            if (other.payTime != null) {
                return false;
            }
        } else if (!payTime.equals(other.payTime)) {
            return false;
        }
        if (platformServiceAgreement == null) {
            if (other.platformServiceAgreement != null) {
                return false;
            }
        } else if (!platformServiceAgreement.equals(other.platformServiceAgreement)) {
            return false;
        }
        if (serviceRate == null) {
            if (other.serviceRate != null) {
                return false;
            }
        } else if (!serviceRate.equals(other.serviceRate)) {
            return false;
        }
        if (withHoldRule == null) {
            if (other.withHoldRule != null) {
                return false;
            }
        } else if (!withHoldRule.equals(other.withHoldRule)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "LoanProjectRelation [id=" + id + ", elcAggrementName=" + elcAggrementName + ", loanAggrementNo="
                + loanAggrementNo + ", custName=" + custName + ", custNo=" + custNo + ", custCode=" + custCode
                + ", coreName=" + coreName + ", coreNo=" + coreNo + ", factoryName=" + factoryName + ", factoryNo="
                + factoryNo + ", balance=" + balance + ", loanBalance=" + loanBalance + ", payDate=" + payDate
                + ", payTime=" + payTime + ", discount=" + discount + ", loanDate=" + loanDate + ", businStatus="
                + businStatus + ", createDate=" + createDate + ", createTime=" + createTime + ", createOperatorName="
                + createOperatorName + ", createOperatorId=" + createOperatorId + ", auditDate=" + auditDate
                + ", auditTime=" + auditTime + ", auditOperatorName=" + auditOperatorName + ", auditOperatorId="
                + auditOperatorId + ", factoryLoanDate=" + factoryLoanDate + ", factoryLoanTime=" + factoryLoanTime
                + ", factoryLoanOperatorName=" + factoryLoanOperatorName + ", factoryLoanOperatorId="
                + factoryLoanOperatorId + ", serviceRate=" + serviceRate + ", withHoldRule=" + withHoldRule
                + ", financingMaturityDate=" + financingMaturityDate + ", accountRegulatoryAgreement="
                + accountRegulatoryAgreement + ", platformServiceAgreement=" + platformServiceAgreement
                + ", dataConfirmationAgreement=" + dataConfirmationAgreement + ", otherAgreements=" + otherAgreements
                + ", custAccountRegulatoryBank=" + custAccountRegulatoryBank + ", custAggregationBank="
                + custAggregationBank + ", custGatheringBank=" + custGatheringBank + ", custWithHoldPrincipalBank="
                + custWithHoldPrincipalBank + ", custWithHoldInterestBank=" + custWithHoldInterestBank
                + ", factoryLoanBank=" + factoryLoanBank + ", factoryGatheringPrincipalBank="
                + factoryGatheringPrincipalBank + ", factoryGatheringInterestBank=" + factoryGatheringInterestBank
                + ", custPayServiceBank=" + custPayServiceBank + "]";
    }

    public void saveCreateValue(CustOperatorInfo info) {

        this.setLoanAggrementNo(assembleRefno());
        this.setCreateDate(BetterDateUtils.getNumDate());
        this.setCreateOperatorId(info.getId());
        this.setCreateOperatorName(info.getName());
        this.setCreateTime(BetterDateUtils.getNumTime());
        this.setId(SerialGenerator.getLongValue("LoanProjectRelation.id"));
        this.setBusinStatus(LoanProjectRelationConstantCollections.RELATION_BUSINSTATUS_NOEFFECTIVE);
        this.setWithHoldRule("7");

    }

    public void saveLoanRecordValue() {

        CustOperatorInfo info = UserUtils.getOperatorInfo();
        this.factoryLoanDate = BetterDateUtils.getNumDate();
        this.factoryLoanTime = BetterDateUtils.getNumTime();
        if (info != null) {

            this.factoryLoanOperatorId = info.getId();
            this.factoryLoanOperatorName = info.getName();
        }

        this.businStatus = LoanProjectRelationConstantCollections.RELATION_BUSINSTATUS_MAKELOANS;

    }

    public LoanProjectElcAgreement getElcAgreementByType(String anType) {

        return LoanProjectElcAgreementConstantCollections.ELCAGREEMENT_TYPE_DATACONFIGM.equals(anType)
                ? this.getDataConfirmationAgreement()
                : LoanProjectElcAgreementConstantCollections.ELCAGREEMENT_TYPE_ACCOUNTREGULATORY.equals(anType)
                        ? this.getAccountRegulatoryAgreement()
                        : LoanProjectElcAgreementConstantCollections.ELCAGREEMENT_TYPE_PLATFORMSERVICE.equals(anType)
                                ? this.getPlatformServiceAgreement() : Collections3.getFirst(this.getOtherAgreements());
    }

    private String assembleRefno() {

        try {

            final String simpleName = this.getClass().getSimpleName();
            final String prefix = "AG";
            final String pattern = prefix + "#{Date:yy}#{Seq:14}";
            final String generateRefNo = SequenceFactory.generate("PLAT_" + simpleName, pattern);
            if (BetterStringUtils.isBlank(generateRefNo)) {
                BTAssert.notNull(null, "获取凭证编号失败!");
            }
            return generateRefNo;
        }
        catch (final Exception e) {
            e.printStackTrace();
            BTAssert.notNull(null, "生成凭证编号失败!");
        }

        return null;
    }

    public void saveLoanFinishValue() {

        CustOperatorInfo info = UserUtils.getOperatorInfo();
        this.auditDate = BetterDateUtils.getNumDate();
        this.auditTime = BetterDateUtils.getNumTime();
        if (info != null) {

            this.auditOperatorId = info.getId();
            this.auditOperatorName = info.getName();
        }

        this.businStatus = LoanProjectRelationConstantCollections.RELATION_BUSINSTATUS_FINISH;

    }

}
